#ifndef __Render_RenderQueue_h__
#define __Render_RenderQueue_h__

#include "RenderOperation.h"

#include <vector>

namespace Orca {

	class IMaterial;
	class IGfxDriver;

	//--------------------------------------------------------------------------
	struct TRenderSlot {

		IMaterial *mtl;
		TRenderOperation *rop;
		float viewDist;
	};
	
	//--------------------------------------------------------------------------
	class IRenderQueueSorter {

	public:
		virtual ~IRenderQueueSorter() {}
		virtual bool compare(const TRenderSlot &lhs, const TRenderSlot &rhs) = 0;
	};

	//--------------------------------------------------------------------------
	class TRenderQueue {

	public:
		TRenderQueue(unsigned short id, IRenderQueueSorter *sorter);
		~TRenderQueue();
		
		unsigned short getId() const;

		void append(IMaterial *mtl, TRenderOperation *rop, float viewDist);
		void reset();
		void render(IGfxDriver *gfxDriver);

	private:
		typedef std::vector<TRenderSlot> TRenderSlotList;
		TRenderSlotList mSlotList;

		IRenderQueueSorter *mSorter;
		unsigned short mId;
		
		struct TRenderQueueCompare {

			IRenderQueueSorter *mSorter;

			bool operator() (const TRenderSlot &lhs, const TRenderSlot &rhs) {

				return mSorter->compare(lhs, rhs);
			}

		};

		void _sortRenderSlotList();
	};
}

#endif	// __Render_RenderQueue_h__